﻿using System;
using System.ComponentModel.DataAnnotations;

using MSAcademic.v2.Infrastructure.Login;
using MSAcademic.v2.Infrastructure.User;

namespace MSAcademic.v2.Web.Areas.Admin.Models.Login
{
    public partial class SignInModel
    {
        public bool HasAuthenticationErrors { get; set; }

        [Required(ErrorMessage = "Molimo unesite korisničko ime.")]
        public string Username { get; set; }

        [DataType(DataType.Password)]
        [Required(ErrorMessage = "Molimo unesite lozinku.")]
        public string Password { get; set; }

        public bool IsLongSession { get; set; }
    }

    public partial class SignInModel
    {
        public IUser User
        {
            get
            {
                if (_user == null)
                {
                    _user = new Lazy<IUser>(() => _loginService.TryGetSignedInUser());
                }
                return _user.Value;
            }
        }
        private Lazy<IUser> _user;
    }

    public partial class SignInModel
    {
        private readonly ILoginService _loginService;

        public SignInModel(
            ILoginService loginService)
        {
            _loginService = loginService;
        }
    }
}